﻿using BankSystemWithCSharp.DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BankSystemWithCSharp
{
    public class ShowMoneyController : IShowMoney
    {
        private Button showButton;
        private Label moneyLabel;
        private BankDataBase BankDB = BankDataBase.Intance;
        private Dictionary<string, bool> ShowMoneyButtonText = new Dictionary<string, bool>()
        {
            {"显示", true },
            {"隐藏", false },
        };
        public ShowMoneyController(Label moneyLabel, Button showButton)
        {
            this.moneyLabel = moneyLabel;
            this.showButton = showButton;
        }
        public void Hide()
        {
            moneyLabel.Text = "********";
            showButton.Text = "显示";
        }
        public void Show()
        {
            moneyLabel.Text = BankDB.GetMoneyNumber().ToString();
            showButton.Text = "隐藏";
        }

        public void ShowMoneyButton_Click(object sender, EventArgs e)
        {
            if (ShowMoneyButtonText[(sender as Button).Text])
            {
                moneyLabel.Text = BankDB.GetMoneyNumber().ToString();
                (sender as Button).Text = "隐藏";
            }
            else
            {
                moneyLabel.Text = "********";
                (sender as Button).Text = "显示";
            }
        }
    }
}